using System;
using System.Collections.Generic;
using System.IO;
using NUnit.Framework;

using NntpClientLib;

namespace NntpClientLibUnitTests
{
    [TestFixture]
    public class ArticleResponseIdsTestFixture
    {
        [Test]
        public void ParseWithTwoArguments()
        {
            Assert.IsNotNull(ArticleResponseIds.Parse("1 a"));
        }

        [Test]
        public void ParseWithTwoArgumentsLong()
        {
            string a1 = "1";
            string a2 = "<asfasdfasdkl@asdfasdfk---asdfasd>";

            ArticleResponseIds a = ArticleResponseIds.Parse(a1 + " " + a2);
            Assert.IsNotNull(a);
            Assert.AreEqual(1, a.ArticleId);
            Assert.AreEqual(a2, a.MessageId);
        }

        [Test]
        public void ParseWithThreeArguments()
        {
            Assert.IsNotNull(ArticleResponseIds.Parse("1 1 1"));
            Assert.IsNotNull(ArticleResponseIds.Parse("a 1 1"));
        }

        [Test]
        public void ParseWithThreeArgumentsLong()
        {
            string a1 = "1";
            string a2 = "<asfasdfasdkl@asdfasdfk---asdfasd>";

            ArticleResponseIds a = ArticleResponseIds.Parse("x " + a1 + " " + a2);
            Assert.IsNotNull(a);
            Assert.AreEqual(1, a.ArticleId);
            Assert.AreEqual(a2, a.MessageId);
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void CheckForNullArgumentCheck()
        {
            ArticleResponseIds.Parse(null);
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void CheckForEmptyStringArgumentCheck()
        {
            ArticleResponseIds.Parse("");
        }

        [Test]
        [ExpectedException(typeof(FormatException))]
        public void CheckForIntParseError()
        {
            ArticleResponseIds.Parse("a a");
        }

        [Test]
        [ExpectedException(typeof(FormatException))]
        public void CheckForIntParseErrorWith3ArgsFirstNumber()
        {
            Assert.IsNotNull(ArticleResponseIds.Parse("1 a 1"));
        }

        [Test]
        [ExpectedException(typeof(FormatException))]
        public void CheckForIntParseErrorWith3ArgsFirstChar()
        {
            Assert.IsNotNull(ArticleResponseIds.Parse("a a 1"));
        }
    }
}
